<?php

class AboutAction extends Action {

    //关于我们
    public function index(){

        $aid = isset($_GET['aid']) ? $_GET['aid'] : 1;

        $data['aid'] = $aid;
        $about = M('about');
        $data['about'] = $about->select();
        $data['content'] = $about->where("aid = '$aid'")->find();

        $this->assign($data);
        $this->display('about');

    }


    //联系我们
    public function contact(){

        //显示用户信息
        $username = isset($_COOKIE['username']) ? $_COOKIE['username'] : "user3";
        $user = M('user');
        $data['user'] = $user->where("username = '$username'")->find();

        //插入留言记录
        $data1['addtime'] = time();
        $data1['content'] = $_POST['content'];
        $data1['uid'] = $data['user']['uid'];
        $msg = M('message');
        $res = $msg->data($data1)->add();
        if($res){
            $this->success('留言成功');
        }
        $this->assign($data);
        $this->display('contact');

    }



}